#include "Logic/LogicEntity.h"
#include "Logic/LogicProcessor.h"
#include "Net/NetEntity.h"
#include "Packet/PacketFactory.h"
#include "Net/Packet.h"

CLogicEntity::CLogicEntity(void)
{
	mNetEntity = nullptr;
}


CLogicEntity::~CLogicEntity(void)
{
}

void CLogicEntity::sendPacket(int msgID, google::protobuf::Message *pMsg)
{
	if (pMsg == nullptr || msgID < 0)
	{
		return;
	}

	if (mNetEntity == nullptr)
	{
		return;
	}

	CLogicProcessor *pProcessor = mNetEntity->getLogicProcessor();
	if (pProcessor == nullptr)
	{
		return;
	}

	CPacket *pPacket = CPacketFactory::GetInstancePtr()->createPacket(msgID, mNetEntity);
	if (pPacket == nullptr)
	{
		return;
	}
	pPacket->mMessage = pMsg;

	pProcessor->SendPacket(pPacket);
}
